package pt.inescid.components.policyengine.heimdall.base;

import pt.inescid.components.policyengine.heimdall.pap.base.ModelDefinition;

public class EventRelevance {
	private ModelDefinition modelDef;
	private String cesName;
	private String cesDomain;
	private String fieldName;
	private int fieldType;
	
	private boolean singleNodeDomain = false;
	
	public EventRelevance(
			ModelDefinition modelDef, 
			String cesName, 
			String cesDomain, 
			String fieldName,
			int fieldType,
			boolean singleNodeDomain) {

		this.modelDef = modelDef;
		this.cesName = cesName;
		this.cesDomain = cesDomain;
		this.fieldName = fieldName;
		this.fieldType = fieldType;
		this.singleNodeDomain = singleNodeDomain;
	}

	public String getCesName() {
		return cesName;
	}

	public String getFieldName() {
		return fieldName;
	}

	public String getEventFieldNameForSQL() {
		return (fieldName.substring(1).replace(".","_"));
	}

	public void setCesName(String cesName) {
		this.cesName = cesName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	/* ===========================================================
	==============================================================
	=============                    =============================
	=============      equals       =============================
	=============                    =============================
	==============================================================
	=========================================================== */
	public boolean equals(Object param) {
		EventRelevance other = (EventRelevance) param;
		
//		if (((this.getCesName() == null && other.getCesName() == null) || 
//				this.getCesName().equals(other.getCesName())) &&
//	((this.getEventFieldName() == null && other.getEventFieldName() == null) || 
//				this.getEventFieldName().equals(other.getEventFieldName()))) {
//	
		if (this.getFieldName() == other.getFieldName()) {
			
			return (true);
		}
		else {
			return (false);
		}
	}

	public String getCesDomain() {
		return cesDomain;
	}

	public void setCesDomain(String cesDomain) {
		this.cesDomain = cesDomain;
	}

	public boolean isSingleNodeDomain() {
		return singleNodeDomain;
	}

	public void setSingleNodeDomain(boolean singleNodeDomain) {
		this.singleNodeDomain = singleNodeDomain;
	}

	public int getFieldType() {
		return fieldType;
	}

	public void setFieldType(int fieldType) {
		this.fieldType = fieldType;
	}
	
	
	public String toString() {
		return (cesName + "[" + cesDomain + "]." + fieldName);
	}

}; // EventRelevance
